//
// Created by 原帅 on 2022/10/2.
//

#ifndef R_RLOGRECORDER_H
#define R_RLOGRECORDER_H

#include "string"
#include "fstream"
#include "map"

/**
 * LOG 文件后缀最大循环编号
 */
#ifndef LOG_FILE_MAX_INDEX
#define LOG_FILE_MAX_INDEX 10
#endif

/**
 * LOG 单个文件最大字节尺寸
 */
#ifndef LOG_FILE_MAX_SIZE
#define LOG_FILE_MAX_SIZE 100000000
#endif

/**
 * LOG 文件路径
 */
#ifndef LOG_FILE_PATH
#define LOG_FILE_PATH "log"
#endif

/**
 * LOG 文件名
 */
#ifndef LOG_FILE_NAME
#define LOG_FILE_NAME "log"
#endif

/**
 * LOG 文件扩展名
 */
#ifndef LOG_FILE_SUFFIX
#define LOG_FILE_SUFFIX "log"
#endif

class RLogRecorder {
public:
    typedef enum {
        ERROR,
        DEBUG,
    } RLOGLEVEL;

private:
    std::string logName;
    uint32_t logCurIndex = 0;
    std::ofstream *ofs;

public:
    RLogRecorder(const std::string logName=LOG_FILE_NAME);

    void recordlog(RLOGLEVEL rloglevel,std::string msg);

    virtual ~RLogRecorder();

protected:
    void checkLogFiles();
    void moveToNextLogFile();
};


#endif //R_RLOGRECORDER_H
